package com.usian.admin.xxlJob

import com.usian.admin.feign.WemediaFeign
import com.usian.admin.service.impl.WemediaNewsAutoScanServiceImpl
import com.xxl.job.core.biz.model.ReturnT
import com.xxl.job.core.handler.annotation.XxlJob
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class WeMediaNewsAutoScanJob {
    //注入远程调用 查询状态为8的文章Id；调用自动审核接口传入状态为8的文章Id进行审核
    @Autowired
    private lateinit var wemediaFeign: WemediaFeign

    @Autowired
    private lateinit var w: WemediaNewsAutoScanServiceImpl

    @XxlJob("wemediaAutoScanJob")
    open fun dosome(param : String) : ReturnT<String>{
        println("自媒体文章审核调度任务开始执行")
        //Id集合不为空走forEach  反之直接返回失败
        (wemediaFeign.findRelease() ?: return ReturnT.FAIL).forEach {
            w.autoScanByMediaNewsId(it.toLong())
        }
        return ReturnT.SUCCESS
    }
    var s1 = "get-element-by-id";
}